Skip to content

fix: resolve failing tests and type errors across api and shared packages#45

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2426-1780938996
Open

fix: resolve failing tests and type errors across api and shared packages#45
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2426-1780938996

Conversation

@stooit

@stooit stooit commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all type errors in the TypeScript Hono API repo. After this change bun test reports 22 pass / 0 fail and bunx tsc --noEmit exits clean (0 errors).

Changes

  • shared/src/utils/pagination.ts — Implemented the previously-stubbed paginate() utility: 1-indexed page slicing (start = (page-1)*size), total, totalPages via Math.ceil with a size > 0 guard, and correct empty-array / partial-last-page handling.
  • api/src/middleware/auth.ts — Fixed the public-route check so it correctly matches HTTP method casing (Hono provides uppercase methods), so POST /users is correctly treated as public. Also made the process.env token lookup safe where process may not be in scope.
  • shared/src/types.ts + api/src/routes/users.ts — Aligned the User type and the users route on a single consistent field name (removed the cross-package mismatch).
  • api/src/routes/users.ts — Added the missing badRequest import, so POST /users returns 400 for missing fields.
  • tsconfig.json — Added bun-types (already installed; no new dependency) to compilerOptions.types so bun:test and the process global resolve under tsc.

Verification

  • bun test → 22 pass, 0 fail
  • bunx tsc --noEmit → exit 0, clean

Notes / assumptions

  • No test files were modified and no dependencies were added, per task constraints.
  • Reviewer noted a pre-existing ?? "test-token" fallback in the auth middleware that silently accepts a hardcoded token when the env token is unset. This predates this work and is out of scope, flagged for awareness.
  • A stale JSDoc comment in types.ts describing the original bug was left in place (cosmetic only).

…ages

- Implement paginate() utility in shared package (page slicing, total, totalPages)
- Fix auth middleware so public-route method check handles HTTP method casing
- Align User type and users route on consistent field name
- Add missing badRequest import in users route
- Include bun-types in tsconfig so bun:test and process resolve (no new deps)

All 22 tests pass; tsc --noEmit is clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant